package lrscp.lib;

import java.util.HashMap;
import java.util.Map;

public class TrackTime {
    static Map<String, Long> lastTimes = new HashMap<String, Long>();

    public static void start(String label) {
        lastTimes.put(label, System.currentTimeMillis());
    }

    private static long stop(String label) {
        Long r = lastTimes.get(label);
        lastTimes.remove(label);
        return System.currentTimeMillis() - r;
    }

    public static String stopAndGetMessage(String label) {
        Long r = lastTimes.get(label);
        lastTimes.remove(label);
        return "TRACK::" + label + ":" + (System.currentTimeMillis() - r);
    }

    public static void stopAndPrintMessage(String label) {
        Log.p(stopAndGetMessage(label));
    }
}
